<!-- 左侧面板 -->
<template>
  <ModelTile class="sdly" title="四大领域" @onMore="onMore" :is-more="true">
    <div class="sdly-item" v-for="item in listData" :key="item.title">
      <div class="title">
        {{ sectorNameTypes.find((type) => type.value == item.sectorName)?.label }}
      </div>
      <div class="desc">
        <span>实际完成：{{ item.aeYtd }}亿 / 目标：{{ item.targetYtd }}亿</span>
        <span>完成率{{ item.targetCr }}%</span>
      </div>
      <div class="pogress">
        <div class="pogress-box">
          <div
            class="pogress-mark"
            :class="[item.targetCr <= 20 ? 'pogress20' : item.targetCr <= 40 ? 'pogress40' : '']"
            :style="{ width: item.targetCr + '%' }"
          ></div>
          <div class="pogress-block" :style="{ left: item.targetCr + '%' }"></div>
        </div>
      </div>
    </div>
  </ModelTile>
</template>

<script lang="ts">
import { ref, defineComponent, computed } from 'vue'
import ModelTile from '@/components/modleTitle/index.vue'
import { useRouter } from 'vue-router'
export default defineComponent({
  name: 'sdly',
  components: {
    ModelTile
  },
  props: {
    // 父级统计数据
    statAllData: {
      type: Object,
      default: {}
    }
  },
  setup(props) {
    const router = useRouter()
    const sectorNameTypes = [
      { value: '0', label: '总体情况' },
      { value: '1', label: '基础设施' },
      { value: '2', label: '工业投资' },
      { value: '3', label: '房地产' },
      { value: '4', label: '社会民生' },
      { value: '5', label: '其他领域' }
    ]
    const listData = computed(
      () =>
        props.statAllData?.sectorInfos || [
          { sectorName: '2', aeYtd: '100', targetYtd: '120', targetCr: 83 },
          { sectorName: '1', aeYtd: '30', targetYtd: '120', targetCr: 25 },
          { sectorName: '4', aeYtd: '60', targetYtd: '120', targetCr: 50 },
          { sectorName: '3', aeYtd: '20', targetYtd: '150', targetCr: 13 }
        ]
    )
    // 跳转页面
    function onMore() {
      console.log('跳转页面')
    }
    return {
      listData,
      sectorNameTypes,
      onMore
    }
  }
})
</script>
<style lang="scss" scoped>
.sdly {
  color: #fff;
  margin-bottom: 64vh * $Bh;

  :deep(.content) {
    padding: 50vh * $Bh 32vw * $w 42vh * $Bh 32vw * $w;
    height: 674vh * $Bh;
    border-radius: 12vh * $Bh;
  }

  .sdly-item {
    height: 114vh * $Bh;

    .title {
      font-size: 28vh * $Bh;
      line-height: 1;
      margin-bottom: 10vh * $Bh;
    }

    .desc {
      font-size: 24vh * $Bh;
      line-height: 58vh * $Bh;
      display: flex;
      justify-content: space-between;
    }

    .pogress {
      height: 16vh * $Bh;

      .pogress-box {
        height: 12vh * $Bh;
        position: relative;

        .pogress-mark {
          height: 12vh * $Bh;
          background: linear-gradient(to right, #188282, #a6fdfd);

          &.pogress20 {
            background: linear-gradient(to right, #862e1c, #f7b0a2);
          }

          &.pogress40 {
            background: linear-gradient(to right, #845a1a, #f6d5a1);
          }
        }

        .pogress-block {
          position: absolute;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
          background-color: #fff;
          box-shadow: 0 0 6vh * $Bh 0 #fff;
          width: 6vw * $w;
          height: 16vh * $Bh;
        }
      }
    }

    & + .sdly-item {
      margin-top: 42vh * $Bh;
    }
  }
}
</style>
